<template>
  <div class="byte-dropdown" @click.stop.prevent>
    <n-dropdown trigger="hover" :options="options" @select="handleSelect">
      <i class="more-icon byte-icon byte-icon--more">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
          <path fill="none" d="M0 0h48v48H0z"></path>
          <path d="M35 21h6v6h-6v-6zm-22 0v6H7v-6h6zm14 0v6h-6v-6h6z"></path>
        </svg>
      </i>
    </n-dropdown>
  </div>
</template>

<script lang="ts" setup>
  defineProps({
    options: {
      type: Array,
      default: () => [
        {
          label: '删除',
          type: 'delete',
          key: '0'
        },{
          label: '编辑',
          type: 'edit',
          key: '1'
        }
      ],
      require: false
    }
  })
  const emits = defineEmits(['operation'])
  const handleSelect = (e) => {
    emits('operation', e)
  }
</script>

<style scoped lang="scss">
  .byte-dropdown {
    display: inline-block;
    .more-icon {
      font-size: 24px;
      color: #4e5969;
    }
    .byte-icon {
      width: 1em;
      height: 1em;
      display: inline-block;
      vertical-align: middle;
      line-height: 1;
      svg {
        width: 100%;
        height: 100%;
        fill: currentColor;
        pointer-events: none;
      }
    }
  }
</style>
